home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_6.lha / 6_6 / tst1.c < prev    next >
Text File  |  1993-08-08  |  1KB  |  53 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <6_6.h>
  6. include <error.h>
  7.  
  8. ain()
  9.  
  10.    string x[100];
  11.    cout << "here we go\n";
  12.    for (int n = 0; cin>>x[n]; n++) 
  13. {
  14. string y;
  15. if (n == 100) error("too many strings");
  16. cout << (y = x[n]) << "\n";
  17. if (y == "done") break;
  18. }
  19.  
  20.    cout << "here we go back again\n";
  21.    for (int i = n-1; 0 <= i; i--)
  22.        cout << x[i] << "\n";
  23.  
  24.    string f = "0123456789";    // creates string "0123456789"
  25.    cout << "f = '" << f << "'\n";
  26.  
  27.    cout << "f(3,3) = '" << f(3,3) << "'\n";
  28.  
  29.    string g = f;
  30.    cout << "g = '" << g << "'\n";
  31.    g(3,3) = "abc";    // creates string "0123456789"
  32.    cout << "g(3,3)='abc' = '" << g << "'\n";
  33.  
  34.    g = f;
  35.    cout << "g = '" << g << "'\n";
  36.    g(3,5) = "abc";    // creates string "0123456789"
  37.    cout << "g(3,5)='abc' = '" << g << "'\n";
  38.  
  39.    g = f;
  40.    cout << "g = '" << g << "'\n";
  41.    g(3,1) = "abc";    // creates string "0123456789"
  42.    cout << "g(3,1)='abc' = '" << g << "'\n";
  43.  
  44.    string f25 = f(2, 4);    // creates string "2345"
  45.    cout << "f25 = '" << f25 << "'\n";
  46.    string f69 = f(6);        // creates string "6789"
  47.    cout << "f69 = '" << f69 << "'\n";
  48.    string f57 = f(-5, 3);    // creates string "567"
  49.    cout << "f57 = '" << f57 << "'\n";
  50.  
  51.    return 0;
  52.  
  53.